def get_url_difference(file_a, file_b, output_file):
    # 读取文件A中的URL集合
    with open(file_a, 'r') as f:
        set_a = set(line.strip() for line in f if line.strip())

    # 读取文件B中的URL集合
    with open(file_b, 'r') as f:
        set_b = set(line.strip() for line in f if line.strip())

    # 计算差集(A中有而B中没有的URL)并按字典序排序
    difference = sorted(set_a - set_b)

    # 将结果写入输出文件
    with open(output_file, 'w') as f:
        for url in difference:
            f.write(url + '\n')


if __name__ == '__main__':
    #做差集a - b => c，得到需要修复的文件名
    file_a = 'oss_batchsnap_list_1.txt'  # 文件A路径
    file_b = '154_batchsnap_list.txt'  # 文件B路径
    output_file = 'c.txt'  # 输出文件路径
    get_url_difference(file_a, file_b, output_file)
